/**
 * FileName: SysLogMapper
 * Author:   秋水浮萍
 * Date:     2020/8/23 20:16
 * Description:
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package com.demo.mapper;

import com.demo.entity.*;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 〈一句话功能简述〉<br>
 * 〈〉
 *
 * @author 秋水浮萍
 * @create 2020/8/23
 * @since 1.0.0
 */
@Repository
public interface SysLogMapper {

    @Select("select claims_number from bus_claims_collateral where collateral_id=#{c}")
    String claimsNumber(String c);

    //添加日志
    @Insert("insert into sys_log (user_id, create_time, msg,operate,claims_number) value(#{userId},#{createTime},#{msg},#{operate},#{claimsNumber})")
    Integer add(SysLog sysLog);

    @Select("select true_name,\n" +
            "       sl.log_id,\n" +
            "       sl.user_id,\n" +
            "       sl.create_time,\n" +
            "       sl.msg,\n" +
            "       sl.operate,\n" +
            "       sl.claims_number\n" +
            "from bus_claims bc\n" +
            "         inner join sys_log sl on bc.claims_number = sl.claims_number\n" +
            "         left join sys_user su on sl.user_id = su.user_id\n" +
            "where bc.create_id = #{userId}\n" +
            "  and bc.disabled = 0 order by create_time desc")
    List<SysLog> syslog1(String userId);

    @Select("select true_name,\n" +
            "       sl.log_id,\n" +
            "       sl.user_id,\n" +
            "       sl.create_time,\n" +
            "       sl.msg,\n" +
            "       sl.operate,\n" +
            "       sl.claims_number\n" +
            "from bus_mortgage bc\n" +
            "         inner join sys_log sl on bc.claims_number = sl.claims_number\n" +
            "         left join sys_user su on sl.user_id = su.user_id\n" +
            "where bc.create_id = #{userId}\n" +
            "  and bc.disabled = 0 order by create_time desc")
    List<SysLog> syslog2(String userId);

    @Select("select true_name,\n" +
            "       sl.log_id,\n" +
            "       sl.user_id,\n" +
            "       sl.create_time,\n" +
            "       sl.msg,\n" +
            "       sl.operate,\n" +
            "       sl.claims_number\n" +
            "from bus_prorig bc\n" +
            "         inner join sys_log sl on bc.claims_number = sl.claims_number\n" +
            "         left join sys_user su on sl.user_id = su.user_id\n" +
            "where bc.create_id = #{userId}\n" +
            "  and bc.disabled = 0 order by create_time desc")
    List<SysLog> syslog3(String userId);
//    @Select("select claims_number from bus_claims_borrow where borrow_id=#{id}")
//    String claimsNumberBor(String id);
//    @Select("select claims_number from bus_claims_borrow where borrow_id=#{id}")
//    String claimsNumberBor(String id);
}
